package com.ldf.jrtsp.enums;

import com.ldf.jrtsp.handler.*;
import com.ldf.jrtsp.parser.RtspDataParser;
import com.ldf.jrtsp.player.RtspPlayer;

/**
 * rtsp options类型
 *
 * @author lidaofu
 * @since 2024/6/19
 **/
public enum RtspOptionsType implements RtspReplyHandle {

    OPTIONS(new RtspOptionReplyHandle()),
    DESCRIBE(new RtspDescribeReplyHandle()),
    SETUP(new RtspSetupReplyHandle()),
    PLAY(new RtspPlayReplyHandle()),
    PAUSE(new RtspPauseReplyHandle()),
    TEARDOWN(new RtspTeardownReplyHandle()),
    GET_PARAMETER(new RtspGetParameterReplyHandle()),
    SET_PARAMETER,
    REDIRECT,
    ANNOUNCE,
    RECORD,
    HEARTBEAT,
    UNKNOWN;

    RtspOptionsType(RtspReplyHandle handler) {
        this.handler = handler;
        this.methodName = this.name() + " ";
    }

    RtspOptionsType() {
        handler = null;
        this.methodName = this.name() + " ";
    }

    private final RtspReplyHandle handler;
    private final String methodName;

    @Override
    public void handle(RtspPlayer player, RtspDataParser rtspDataParser) {
        if (this.handler != null) {
            this.handler.handle(player, rtspDataParser);
        }
    }

    public String getMethodName() {
        return methodName;
    }


}
